//
//  todayCollectionViewCell.m
//  pb
//
//  Created by 千翼网络科技 on 2017/5/5.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "todayCollectionViewCell.h"

@implementation todayCollectionViewCell

-(id)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        _numberLabel = [[UILabel alloc]init];
//        _numberLabel.text = @"南方航空 CZ545";
        _numberLabel.textColor = getColor(@"ffffff");
        _numberLabel.textAlignment = NSTextAlignmentCenter;
        _numberLabel.font = get4sFont(12);
        [self addSubview:_numberLabel];
        [_numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self).with.offset(screenScale(40));
            make.left.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(screenScale(410));
            make.height.mas_equalTo(screenScale(28));
        }];
        
        _startLocationLabel = [[UILabel alloc]init];
//        _startLocationLabel.text = @"巴基斯坦";
        _startLocationLabel.textColor = getColor(@"ffffff");
        _startLocationLabel.textAlignment = NSTextAlignmentCenter;
        _startLocationLabel.font = get4sFont(11);
        [self addSubview:_startLocationLabel];
        [_startLocationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self).with.offset(screenScale(90));
            make.left.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(screenScale(145));
            make.height.mas_equalTo(screenScale(24));
        }];
        
        _startAirportLabel = [[UILabel alloc]init];
//        _startAirportLabel.text = @"巴基斯坦机场";
        _startAirportLabel.textColor = getColor(@"ffffff");
        _startAirportLabel.textAlignment = NSTextAlignmentCenter;
        _startAirportLabel.font = get4sFont(11);
        [self addSubview:_startAirportLabel];
        [_startAirportLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_startLocationLabel.mas_bottom).with.offset(screenScale(25));
            make.left.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(screenScale(145));
            make.height.mas_equalTo(screenScale(24));
        }];
        
        _startTimeLabel = [[UILabel alloc]init];
//        _startTimeLabel.text = @"9:00";
        _startTimeLabel.textColor = getColor(@"ffffff");
        _startTimeLabel.textAlignment = NSTextAlignmentCenter;
        _startTimeLabel.font = get4sFont(13);
        [self addSubview:_startTimeLabel];
        [_startTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_startAirportLabel.mas_bottom).with.offset(screenScale(25));
            make.left.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(screenScale(145));
            make.height.mas_equalTo(screenScale(26));
        }];
        
        ///
        
        _rightImg = [[UIImageView alloc]init];
        _rightImg.image = [UIImage imageNamed:@"arroiw"];
        [self addSubview:_rightImg];
        [_rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_startLocationLabel.mas_bottom).with.offset(screenScale(3));
            make.left.mas_equalTo(self).with.offset(screenScale(190));
            make.width.mas_equalTo(screenScale(46));
            make.height.mas_equalTo(screenScale(18));
        }];
        
        _allTimeLabel = [[UILabel alloc]init];
//        _allTimeLabel.text = @"3个小时03分";
        _allTimeLabel.textColor = getColor(@"ffffff");
        _allTimeLabel.textAlignment = NSTextAlignmentCenter;
        _allTimeLabel.font = get4sFont(10);
        [self addSubview:_allTimeLabel];
        [_allTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_startAirportLabel.mas_bottom).with.offset(screenScale(27));
            make.left.mas_equalTo(self).with.offset(screenScale(125));
            make.width.mas_equalTo(screenScale(410) - screenScale(125)*2);
            make.height.mas_equalTo(screenScale(24));
        }];
        
        ///
        
        _endLocationLabel = [[UILabel alloc]init];
//        _endLocationLabel.text = @"阿富汗";
        _endLocationLabel.textColor = getColor(@"ffffff");
        _endLocationLabel.textAlignment = NSTextAlignmentCenter;
        _endLocationLabel.font = get4sFont(11);
        [self addSubview:_endLocationLabel];
        [_endLocationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self).with.offset(screenScale(90));
            make.right.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(screenScale(145));
            make.height.mas_equalTo(screenScale(24));
        }];
        
        _endAirportLabel = [[UILabel alloc]init];
//        _endAirportLabel.text = @"阿富汗机场";
        _endAirportLabel.textColor = getColor(@"ffffff");
        _endAirportLabel.textAlignment = NSTextAlignmentCenter;
        _endAirportLabel.font = get4sFont(11);
        [self addSubview:_endAirportLabel];
        [_endAirportLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_startLocationLabel.mas_bottom).with.offset(screenScale(25));
            make.right.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(screenScale(145));
            make.height.mas_equalTo(screenScale(24));
        }];
        
        _endTimeLabel = [[UILabel alloc]init];
//        _endTimeLabel.text = @"12:03";
        _endTimeLabel.textColor = getColor(@"ffffff");
        _endTimeLabel.textAlignment = NSTextAlignmentCenter;
        _endTimeLabel.font = get4sFont(13);
        [self addSubview:_endTimeLabel];
        [_endTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_startAirportLabel.mas_bottom).with.offset(screenScale(25));
            make.right.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(screenScale(145));
            make.height.mas_equalTo(screenScale(26));
        }];
        
        UIView *threadView = [[UIView alloc]init];
        threadView.backgroundColor = getColor(@"ffffff");
        [self addSubview:threadView];
        [threadView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_endTimeLabel.mas_bottom).with.offset(screenScale(10));
            make.left.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(screenScale(410));
            make.height.mas_equalTo(screenScale(1));
        }];
        
        ///
        
        _messageTextView = [[UITextView alloc]init];
        _messageTextView.editable = NO;
        _messageTextView.backgroundColor = getMainColor();
        [self addSubview:_messageTextView];
        [_messageTextView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(threadView.mas_bottom).with.offset(screenScale(15));
            make.left.mas_equalTo(self).with.offset(screenScale(20));
            make.right.mas_equalTo(self).with.offset(screenScale(-20));
            make.bottom.mas_equalTo(self).with.offset(screenScale(-20));
        }];
        
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        paragraphStyle.lineSpacing = screenScale(10);// 字体的行间距
        
        NSDictionary *attributes = @{NSParagraphStyleAttributeName:paragraphStyle};
        _messageTextView.attributedText = [[NSAttributedString alloc] initWithString:@"" attributes:attributes];
        _messageTextView.textColor = getColor(@"ffffff");
        _messageTextView.font = get4sFont(10);
        
        UIView *bgView = [[UIView alloc]init];
        [self addSubview:bgView];
        [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(threadView.mas_bottom).with.offset(screenScale(15));
            make.left.mas_equalTo(self).with.offset(screenScale(20));
            make.right.mas_equalTo(self).with.offset(screenScale(-20));
            make.bottom.mas_equalTo(self).with.offset(screenScale(-20));
        }];
    }
    return self;
}

@end
